package com.fzq.design.singleton;

/**
 * @Author 樊志强
 **/
public class Main {
    public static void main(String[] args) {
        System.out.println("--------饿汉模式--------");
        SingletonStaticConstant singleton1_StaticMethod = SingletonStaticConstant.getInstance();
        SingletonStaticConstant singletonStaticConstant_2 = SingletonStaticConstant.getInstance();
        System.out.println("静态常量_1: " + singleton1_StaticMethod.hashCode());
        System.out.println("静态常量_2: " + singletonStaticConstant_2.hashCode());

        SingletonStaticBlock singletonStaticBlock_1 = SingletonStaticBlock.getInstance();
        SingletonStaticBlock singletonStaticBlock_2 = SingletonStaticBlock.getInstance();
        System.out.println("静态代码快_1: " + singletonStaticBlock_1.hashCode());
        System.out.println("静态代码块_2: " + singletonStaticBlock_2.hashCode());

        System.out.println("--------懒汉模式--------");
        SingletonDoubleCheck doubleCheck_1 = SingletonDoubleCheck.getInstance();
        SingletonDoubleCheck doubleCheck_2 = SingletonDoubleCheck.getInstance();
        System.out.println("双重检查_1: " + doubleCheck_1.hashCode());
        System.out.println("双重检查_2: " + doubleCheck_2.hashCode());

        SingletonStaticInnerClass innerClass_1 = SingletonStaticInnerClass.getInstance();
        SingletonStaticInnerClass innerClass_2 = SingletonStaticInnerClass.getInstance();
        System.out.println("静态内部类_1: " + innerClass_1.hashCode());
        System.out.println("静态内部类_2: " + innerClass_2.hashCode());

        SingletonEnum singletonEnum_1 = SingletonEnum.INSTANCE;
        SingletonEnum singletonEnum_2 = SingletonEnum.INSTANCE;
        System.out.println("枚举_1: " + singletonEnum_1.hashCode());
        System.out.println("枚举_2: " + singletonEnum_2.hashCode());
    }
}
